package com.lmaye.design.patterns.ood.lsp.comply;

import java.math.BigDecimal;

/**
 * -- Animal
 *
 * @author lmay.Zhou
 * @date 2020/11/12 19:57 星期四
 * @qq 379839355
 * @email lmay@lmaye.com
 * @since JDK1.8
 */
public abstract class Animal {
    /**
     * 奔跑速度
     */
    protected double runSpeed;

    /**
     * 获取奔跑时间
     *
     * @param distance 距离
     * @return double
     */
    public double getRunTime(double distance) {
        return new BigDecimal(distance / runSpeed).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
    }

    public void setRunSpeed(double runSpeed) {
        this.runSpeed = runSpeed;
    }
}
